<?php

include_once '../../../Core/Conexion.php';
include_once '../../../Core/Controlador.php';
include_once '../../../Core/InterfazDatos.php';
include_once '../../entidades/Usuario.php';
include_once '../../entidades/Profesor.php';
include_once '../../entidades/Suscripcion.php';

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Crear
 *
 * @author cHr15t14n
 */
class Crear extends Controlador {

    function __construct() {
        parent::__construct();
    }

    public function ejecutar() {
        $hoy = getdate();
        //echo $hoy[year]."-".$hoy[mon]."-".$hoy[mday]." ".$hoy[hours].":".$hoy[minutes].":".$hoy[seconds];
        //echo $_POST['nick'], $_POST['clave'];
        //1 administrador 2 profeso 3 general
        $usuario = new Usuario($_POST['nick'], $_POST['clave'], $hoy[year] . "-" . $hoy[mon] . "-" . $hoy[mday] . " " . $hoy[hours] . ":" . $hoy[minutes], $hoy[year] . "-" . $hoy[mon] . "-" . $hoy[mday] . " " . $hoy[hours] . ":" . $hoy[minutes], 2, 0);
        $this->conexion->grabar($usuario);
        $suscripcion = new Suscripcion(0, $hoy[year] . "-" . $hoy[mon] . "-" . $hoy[mday] . " " . $hoy[hours] . ":" . $hoy[minutes], 0, 0, 0, 0);
        $this->conexion->grabar($suscripcion);
        $consulta = $this->conexion->consultaLibre("SELECT idSuscripcion FROM SUSCRIPCION LIMIT 1");

        $fila = mysql_fetch_array($consulta);

        do {
            $idSuscripcion = $fila[0];
        } while ($fila = mysql_fetch_array($consulta));

        $profesor = new Profesor(0, $idSuscripcion[0], $_POST['nick'], $_POST['cedula'], $_POST['nombres'], $_POST['apellidos'], $_POST['titulo'], $_POST['telefono'], $_POST['celular'], $_POST['email'], $_POST['descripcion']);
        $this->conexion->grabar($profesor);
        header("Location: ../confirmacionRegistro.php?nombre=");
    }

//put your code here
}

$controlador = new Crear();
$controlador->ejecutar();
